import {TimeControllerOpt} from "../../controller/model/ControllerOpt";
import {TimeController} from "../../controller/TimeController";
import Configer from "../../frame/apiModel/config/Configer";
import {FinalKey} from "../../constant/FinalConstant";
import {ConfigKey, ResumeType} from "../../constant/ConfigConstant";
import {Util} from "../../utils/Util";
import {GlobalEnv} from "../../utils/GlobalEnv";
import {UnitAttribute, AttributeEnum} from "../../frame/dataSource/DataModel";
import {GuiController} from "../../controller/GuiController";
import {CaluAttrStr, SpecialEffectType} from "../../type/Type";
import {AbilityController} from "../../controller/AbilityController";
import {UnitController} from "../../controller/UnitController";
import {PlayerFactory} from "../../frame/PlayerFactory";
import {PlayerModel} from "../../frame/apiModel/adapterModel/model4/PlayerModel";
import {Logger} from "../../frame/apiModel/config/Logger";
import {UnitModel} from "../../frame/apiModel/adapterModel/model3/UnitModel";
import {GlobalModel} from "../../frame/apiModel/adapterModel/model1/GlobalModel";
import {UnitDataKey} from "../../frame/dataSource/DataSource";
import {TriggerFactory} from "../../frame/TriggerFactory";
import {DataRouter} from "../../frame/dataSource/DataRouter";
import {CodeUtil} from "../../frame/codeAdapter/CodeUtil";
import {DataRouterUtil} from "../../utils/router/DataRouterUtil";
import {TextGuiKey} from "../../constant/UIConfig";

export function forbiddenTrigger() {
    const unitDatas = DataRouter.getUnitDatas();
    for (let i = 0; i < unitDatas.length; i++) {
        const unitData = unitDatas[i];
        const forbiddenArea = unitData.forbiddenArea;
        if (forbiddenArea) {
            const forbiddenMode = unitData.forbiddenMode;
            const forbiddenText = unitData.forbiddenText;
            const forbiddenAreaArr = CodeUtil.getArrBySplit(forbiddenArea);
            const forbiddenModeArr = CodeUtil.getArrBySplit(forbiddenMode);
            const forbiddenTextArr = CodeUtil.getArrBySplit(forbiddenText);
            for (let j = 0; j < forbiddenAreaArr.length; j++) {
                const mode = DataRouterUtil.getNumByArr(forbiddenModeArr, j);
                if (mode && mode >= 0) {
                    const difficult = GlobalEnv.difficult;
                    const difficultData = DataRouterUtil.getDifficultData(difficult);
                    if (mode === difficultData.mode) {
                        const area = forbiddenAreaArr[j];
                        const text = forbiddenTextArr[j];
                        if (area) {
                            const unitId = unitData.id;
                            if (unitId) {
                                const pathCallBack = function (toast: string, activeUnit: UnitModel, player: PlayerModel) {
                                    if (toast) {
                                        Logger.toastProduct(toast, player)
                                    }
                                    const startLoc = player.startLocation;
                                    player.moveUnit(activeUnit, startLoc, false)
                                }
                                UnitController.getInstance().registUnitForbidden(area, unitId, text, pathCallBack)
                            }
                        }
                    }
                }
            }
        }
    }
    // const rangeName = Configer.getFinal(FinalKey.noPetRange);
    // if (rangeName) {
    //
    // }
}
